from flask import Flask
from flask_sqlalchemy import SQLAlchemy
import redis
from config import Config
from flask_session import Session
from flask_wtf import CSRFProtect
from flask_script import Manager
from flask_migrate import Migrate,MigrateCommand
from info import creat_app,db


# app = Flask(__name__)


# class Config(object):
#
#     DEBUGE = True
#     SQLALCHEMY_DATABASE_URI='mysql://root:mysql@127.0.0.1:3306/information_10'
#     SQLALCHEMY_TRACK_MODIFICATIONS=True
#     #redis配置
#     redis_host='127.0.0.1'
#     redis_port=6379
#     #配置密钥
#     SECRET_KEY='KFJAKFNKAHRTIJNZH+/addkhjijkkaadad'
#
#     #session配置
#     SESSION_TYPE='redis'    #指定存到redis
#     SESSION_REDIS=redis.StrictRedis(host=redis_host,port=redis_port) #创建redis对象,用于储存短信验证码
#     SESSION_USE_SIGNER=True     #让cookie中的session 被签名加密处理
#     PERMANET_SESSION_LIFETIME=86400     #过期时间，可以随意设置


# app.config.from_object(Config)
#
# db = SQLAlchemy(app)
#
# store_redis = redis.StrictRedis(host=Config.redis_host,port=Config.redis_port)
#
# #开启CSRF保护
# CSRFProtect(app)
#
# #开启session
# Session(app)
app = creat_app('developement')

manager=Manager(app)

#数据库迁移
Migrate(app,db)

#添加迁移命令
manager.add_command('xxx',MigrateCommand)

# @app.route('/')
# def index():
#
#     return 'index'


if __name__ =='__main__':

    manager.run()
